﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FrameworkLib.Filters
{
    public partial class FilterControl : UserControl
    {
        public event EventHandler ResetFilter;
        public event EventHandler RefrehData;
  
        private object m_theContainer = null;

        public object TheContainer
        {
            get { return m_theContainer; }
            set
            {
                m_theContainer = value;

                if (m_theContainer != null)
                {
                    this.popupContainerEdit1.Properties.PopupControl = (DevExpress.XtraEditors.PopupContainerControl)m_theContainer;
                }
            }
        }

        public FilterControl()
        {
            InitializeComponent();

            this.popupContainerEdit1.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(popupContainerEdit1_ButtonClick);
        }

        void popupContainerEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Close)
            {
                if (ResetFilter != null)
                {
                    ResetFilter(this, EventArgs.Empty);
                }
            }

            if (e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Redo)
            {
                if (RefrehData != null)
                {
                    RefrehData(this, EventArgs.Empty);
                }
            }
        }        
    }
}
